﻿namespace ToRTalent {
    using System;
    using System.Collections.Generic;
    using System.Net;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    public static class Address {

        private static string _address = "";
        public static string AddressString {
            get{ return _address; }
            set{
                if( value != null )
                    _address = value;
            }
        }

        private static string _base = "";
        public static string BaseAddress {
            get { return _base; }
            set {
                if( value != null )
                    _base = value;
            }
        }

        private static string _points = "";
        public static string TalentString {
            get { return _points; }
            set {
                if( value != null )
                    _points = value;
            }
        }

        public static bool IsNew { get; set; }

        public static void ParseAddress() {
            string address = System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString();
            IsNew = !address.Contains( "#" );

            if( IsNew )
                BaseAddress = address;
            else {
                string[] split = address.Split( '#' );
                BaseAddress = split[ 0 ];
                ExpandTalents( split[ 1 ] );
            }
        }

        public static void CondenseTalents( string address ) {
            List<int> buildList = new List<int>();
            StringBuilder builder = new StringBuilder();
            string[] split = address.Split( '#' );
            string className = String.Empty;
            int numOut;

            for( int i = 0; i < address.Length; i++ ) {
                if( !Int32.TryParse( address[ i ].ToString(), out numOut ) )
                    className += address[ i ].ToString();
                else
                    buildList.Add( numOut );
            }

            string classAbrv = className.Substring( 0, 2 );


        }

        public static void ExpandTalents( string address ) {
            System.Windows.Browser.HtmlPage.Window.Navigate( new Uri( address ), "_blank" );
        }
    }
}
